<head>
    <link href="/css/fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
</head>
<v-box>
    <input id="fileupload" class="file-loading" type="file" multiple name="file" enctype="multipart/form-data">
</v-box>
<script src="../js/plugins/piexif.min.js" type="text/javascript"></script>
<script src="../js/fileinput.min.js" type="text/javascript"></script>
<script src="../js/locales/zh.js" type="text/javascript"></script>


<script>
    var vm = new Vue({
        el: '#app',
        data: {},
        methods:{
            openDetail:function () {
                layer.open({
                    type: 2,
                    title: 'title" />',
                    shadeClose: true,
                    shade: 0.5,
                    maxmin: true,
                    area: ['90%', '90%'],
                    content: '/admin/attachments/attachment?attachId=' + id,
                    scrollbar: false
                });
            },
            loadFileInput:function () {
                $("#fileupload").fileinput({
                    language: 'zh',
                    uploadUrl: '/admin/attachments/upload',
                    uploadAsync: true,
                    allowedFileExtensions: ['jpg','gif','png','jpeg','svg','psd'],
                    maxFileCount: 100,
                    enctype : 'multipart/form-data',
                    showClose: false
                }).on("fileuploaded",function (event , data , previewId , index) {
                    var data = data.jqXHR.responseJSON;
                    if(data.success=="1"){
                        $("#uploadForm").hide(400);
                        $.toast({
                            text: data.message,
                            heading: '<@spring.message code="common.text.tips" />',
                            icon: 'success',
                            showHideTransition: 'fade',
                            allowToastClose: true,
                            hideAfter: 1000,
                            stack: 1,
                            position: 'top-center',
                            textAlign: 'left',
                            loader: true,
                            loaderBg: '#ffffff',
                            afterHidden: function () {
                                window.location.reload();
                            }
                        });
                    }
                });
            }

        },
        mounted () {
            debugger;
            $("#fileupload").fileinput({
                language: 'zh',
                uploadUrl: '/admin/attachments/upload',
                uploadAsync: true,
                allowedFileExtensions: ['jpg','gif','png','jpeg','svg','psd'],
                maxFileCount: 100,
                enctype : 'multipart/form-data',
                showClose: false
            }).on("fileuploaded",function (event , data , previewId , index) {
                var data = data.jqXHR.responseJSON;
                if(data.success=="1"){
                    $("#uploadForm").hide(400);
                    $.toast({
                        text: data.message,
                        heading: '<@spring.message code="common.text.tips" />',
                        icon: 'success',
                        showHideTransition: 'fade',
                        allowToastClose: true,
                        hideAfter: 1000,
                        stack: 1,
                        position: 'top-center',
                        textAlign: 'left',
                        loader: true,
                        loaderBg: '#ffffff',
                        afterHidden: function () {
                            window.location.reload();
                        }
                    });
                }
            });
        }
    })

    $(document).on('pjax:complete',function () {
        $("#fileupload").fileinput({
            language: 'zh',
            uploadUrl: '/admin/attachments/upload',
            uploadAsync: true,
            allowedFileExtensions: ['jpg','gif','png','jpeg','svg','psd'],
            maxFileCount: 100,
            enctype : 'multipart/form-data',
            showClose: false
        }).on("fileuploaded",function (event , data , previewId , index) {
            var data = data.jqXHR.responseJSON;
            if(data.success=="1"){
                $("#uploadForm").hide(400);
                $.toast({
                    text: data.message,
                    heading: '<@spring.message code="common.text.tips" />',
                    icon: 'success',
                    showHideTransition: 'fade',
                    allowToastClose: true,
                    hideAfter: 1000,
                    stack: 1,
                    position: 'top-center',
                    textAlign: 'left',
                    loader: true,
                    loaderBg: '#ffffff',
                    afterHidden: function () {
                        window.location.reload();
                    }
                });
            }
        });
    });
</script>